import request from '@/utils/request'
import { camelCaseObject } from '@/libs/object'

const AUTH_PREFIX_V1 = `/api/v1/rds`

export function getRdsDatabaseList(params) {
  return request.get(`${AUTH_PREFIX_V1}/databases`, { params }).then(res => camelCaseObject(res))
}

export function getRdsDatabaseListByPage(params) {
  return request.get(`${AUTH_PREFIX_V1}/databases/page`, { params }).then(res => camelCaseObject(res))
}

export function getRdsDatabase(databaseId) {
  return request.get(`${AUTH_PREFIX_V1}/databases/${databaseId}`).then(res => camelCaseObject(res))
}

export function createRdsDatabase(params) {
  return request.post(`${AUTH_PREFIX_V1}/databases`, params).then(res => camelCaseObject(res))
}

export function updateRdsDatabase(databaseId, params) {
  return request.put(`${AUTH_PREFIX_V1}/databases/${databaseId}`, params).then(res => camelCaseObject(res))
}

export function deleteRdsDatabase(databaseId) {
  return request.delete(`${AUTH_PREFIX_V1}/databases/${databaseId}`).then(res => camelCaseObject(res))
}
